<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>回收站</title>
		<link type="text/css" rel="stylesheet" href="../jquery-easyui-1.4.2/themes/default/easyui.css">
		<link type="text/css" rel="stylesheet" href="../jquery-easyui-1.4.2/themes/icon.css">
		<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
		<script type="text/javascript" src="../jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
		
		<style type="text/css">
			#outBox_span{
				font-weight: bold;
				font-size: 14px;
				cursor:default;
				text-decoration: none;
			}
			#div_a a{
				display: block;
				margin-right: 20px;
				float:right;
			}
			#div_a{
				margin-right: 20px;
				padding-bottom:20px ;
			}
			.datagrid-header-row td{
   		 		background-color:#59b8e7;
   		 		font-weight:bold;
   		 		color:#fff;
   		 	}
		</style>
		<script type="text/javascript">
			$(function(){
				var userId = $("#userId").val();
				$("#tableOutBox").datagrid({
					url:'../email/loadRecycleOutBox.do',
					pagination:true,
					queryParams:{pageNo:1,pageSize:10,userId:userId},
					/*  ,keyword:"",direction:""*/
					rownumbers:true,
					striped:true,
					frozenColumns:[[{field:'hhhh',width:50,checkbox:true}]],
					columns:[[
					      {field:'mid',title:'编号',width:100,hidden:true},
					      {field:'title',title:'标题',width:100,align:'center'},
					      {field:'content',title:'内容',width:200,align:'center'},
					      {field:'addresser',title:'发件人',width:100,align:'center'},
					      {field:'recipients',title:'收件人',width:100,align:'center'},
					      {field:'stringDate',title:'编写日期',width:200,align:'center'}
					]]
				});
				var page = $("#tableOutBox").datagrid("getPager");
				page.pagination({
					onSelectPage:function(pageNumber,pageSize){
						$("#tableOutBox").datagrid('load',{pageNo:pageNumber,pageSize:pageSize,userId:userId});
						page.pagination({
							pageNumber:pageNumber,
							pageSize:pageSize,
							userId:userId
							/* keyword:"",
							direction:"" */
						});
					}
				});
				$("#tableInBox").datagrid({
					url:'../email/loadRecycleInBox.do',
					pagination:true,
					queryParams:{pageNo:1,pageSize:10,userId:userId},
					/*  ,keyword:"",direction:""*/
					rownumbers:true,
					striped:true,
					frozenColumns:[[{field:'hhhh',width:50,checkbox:true}]],
					columns:[[
					      {field:'mid',title:'编号',width:100,hidden:true},
					      {field:'title',title:'标题',width:100,align:'center'},
					      {field:'content',title:'内容',width:200,align:'center'},
					      {field:'addresser',title:'发件人',width:100,align:'center'},
					      {field:'recipients',title:'收件人',width:100,align:'center'},
					      {field:'stringDate',title:'编写日期',width:200,align:'center'}
					]]
				});
				var page = $("#tableInBox").datagrid("getPager");
				page.pagination({
					onSelectPage:function(pageNumber,pageSize){
						$("#tableInBox").datagrid('load',{pageNo:pageNumber,pageSize:pageSize,userId:userId});
						page.pagination({
							pageNumber:pageNumber,
							pageSize:pageSize,
							userId:userId
							/* keyword:"",
							direction:"" */
						});
					}
				});
			});
			//测底删除发件箱数据
			function deleteOutBox(){
				var selections = $("#tableOutBox").datagrid("getSelections");
				if(selections.length == 0){
					$.messager.alert("错误","请选中要删除的信息！","error");
					return;
				}
				var temp = new Array();
				var i = 0;
				for(i;i<selections.length;i++){
					temp.push(selections[i].mid);
				}
				 $.messager.confirm('确认信息','您确定要测底删除'+i+'条发件箱数据？',function(r){
					if(r){
						  $.post("../email/deleteById.do",{mid:temp},function(data){
						    	$('#tableOutBox').datagrid("reload");
						});  
					}  
				}); 
			}
			//恢复收件箱数据
			function recoverOutBox(){
				var selections = $("#tableOutBox").datagrid("getSelections");
				if(selections.length == 0){
					$.messager.alert("错误","请选中要删除的信息！","error");
					return;
				}
				var temp = new Array();
				var i = 0;
				for(i;i<selections.length;i++){
					temp.push(selections[i].mid);
				}
				 $.messager.confirm('确认信息','您确定要恢复'+i+'条到发件箱？',function(r){
					if(r){
						  $.post("../email/recoverData.do",{mid:temp},function(data){
						    	$('#tableOutBox').datagrid("reload");
						});  
					}  
				}); 
			}
			//测底删除收件箱数据
			function deleteInBox(){
				var selections = $("#tableInBox").datagrid("getSelections");
				if(selections.length == 0){
					$.messager.alert("错误","请选中要删除的信息！","error");
					return;
				}
				var temp = new Array();
				var i = 0;
				for(i;i<selections.length;i++){
					temp.push(selections[i].mid);
				}
				 $.messager.confirm('确认信息','您确定要测底删除'+i+'条发件箱数据？',function(r){
					if(r){
						  $.post("../email/deleteById.do",{mid:temp},function(data){
						    	$('#tableInBox').datagrid("reload");
						});  
					}  
				}); 
			}
			//恢复收件箱数据
			function recoverInBox(){
				var selections = $("#tableInBox").datagrid("getSelections");
				if(selections.length == 0){
					$.messager.alert("错误","请选中要删除的信息！","error");
					return;
				}
				var temp = new Array();
				var i = 0;
				for(i;i<selections.length;i++){
					temp.push(selections[i].mid);
				}
				 $.messager.confirm('确认信息','您确定要恢复'+i+'条到发件箱？',function(r){
					if(r){
						  $.post("../email/recoverData.do",{mid:temp},function(data){
						    	$('#tableInBox').datagrid("reload");
						});  
					}  
				}); 
			}
		</script>
	</head>
	<body class="easyui-layout" style="margin: auto;">
		<div data-options="region:'north'" style="height:33px;padding:5px 0px 0px 5px">
			<span id="outBox_span">
				<span class="easyui-linkbutton" plain="true" iconCls="icon-recycle"></span>回收站
			</span>
		</div>
		<div data-options="region:'center'">
		<input id="userId" type="hidden" value="${user.userId}">
		<br />
			<div id="div_a">
				<a href="javascript:deleteOutBox();">测底删除</a>
				<a href="javascript:recoverOutBox();">恢复到发件箱</a>	
			</div>
			<table id="tableOutBox" class="easyui-datagrid" style="width:98%;"title="发件箱" iconCls="icon-save">
				
			</table>
			<br />
			<div id="div_a">
				<a href="javascript:deleteInBox();">测底删除</a>
				<a href="javascript:recoverInBox();">恢复到收件箱</a>	
			</div>
			<table id="tableInBox" class="easyui-datagrid" style="width:98%;"title="收件箱" iconCls="icon-save">
		
			</table>
		</div>
	</body>
</html>
